package com.zy.ivideo.service;

import com.zy.ivideo.entity.ResponseEntity;
import com.zy.ivideo.entity.unionentity.IUnionVideoMutilEntity;
import com.zy.ivideo.repository.VideoMultitypeRepository;
import com.zy.ivideo.utils.ResponseUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class VideoMutilEntityService {
    @Autowired
    VideoMultitypeRepository repository;

    /**
     * 根据视频分类获取对应的视频信息
     * @param typeid
     * @param page
     * @param pagesize
     * @return
     */
    public ResponseEntity<List<IUnionVideoMutilEntity>> getMutilVideoByTypeId(int typeid, int page, int pagesize){
        List<IUnionVideoMutilEntity> result = repository.getMutilVideoByTypeId(typeid, page, pagesize);
        if (result==null||result.size()==0){
            return ResponseUtils.failed("没有获取到对应视频信息");
        }
        return ResponseUtils.success(result);
    }

    /**
     * 获取推荐视频信息
     * @param page
     * @param pagesize
     * @return
     */
    public ResponseEntity<List<IUnionVideoMutilEntity>> getRecommendMutilVideo(int page,int pagesize){
        List<IUnionVideoMutilEntity> result = repository.getRecommendMutilVideo(page, pagesize);
        if (result==null||result.size()==0){
            return ResponseUtils.failed("没有获取到对应视频信息");
        }
        return ResponseUtils.success(result);
    }
}
